package cc.z8g.browser.utils

import android.app.DownloadManager
import android.app.NotificationManager
import android.content.ClipboardManager
import android.content.Context
import android.view.inputmethod.InputMethodManager
import cc.z8g.browser.BrowserApp

/**
 * SystemService 统一收敛到这里，避免到处持有引用
 * @author zhaoxuyang.net
 * @since 2024-08-07
 */
object SystemServiceManager {

    val clipboardManager: ClipboardManager by lazy { getService(Context.CLIPBOARD_SERVICE) as ClipboardManager }
    val inputMethodManager: InputMethodManager by lazy { getService(Context.INPUT_METHOD_SERVICE) as InputMethodManager }
    val notificationManager: NotificationManager by lazy { getService(Context.NOTIFICATION_SERVICE) as NotificationManager }
    val downloadManager: DownloadManager by lazy { getService(Context.DOWNLOAD_SERVICE) as DownloadManager }
    /** 获取系统服务 */
    private fun getService(name: String): Any = BrowserApp.getApplication().getSystemService(name)
}